﻿using AdverseEventReportSystem.BLL;
using AdverseEventReportSystem.BLL.ServiceReference1;
using AdverseEventReportSystem.Core;
using AdverseEventReportSystem.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AdverseEventReportSystem.Web.Areas.Personnel.Controllers
{
    public class NurseTransferReviewController : BaseController
    {
        // GET: Personnel/NurseTransferReview
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 转科申请列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Search()
        {
            int pageIndex = DataConvert.StrToInt(Request["page"], 1);
            int pageSize = DataConvert.StrToInt(Request["pageSize"], ConfigHelper.GetConfigInt("pagesize"));
            int status = DataConvert.StrToInt(Request["status"]);
            string name = DataConvert.ToString(Request["name"]);
            string areaId = DataConvert.ToString(Request["areaId"]);
            string departmentCode = "";
            if (areaId == "-1")
            {
                departmentCode = loginUser.DepartCode;
            }
            else
            {
                departmentCode = areaId;
            }

            FunctionAndPermissionsSoapClient service = new FunctionAndPermissionsSoapClient();
            ResultHelperOfSkip serviceResult = service.getP_NurseTransferList(status.ToString(), name, departmentCode, pageIndex, pageSize, "");
            DataTable dt = new DataTable();
            int total = 0;
            if (serviceResult.S)
            {
                dt = serviceResult.D.DT;
                total = serviceResult.D.RowNum;
            }

            var result = new { Total = total, Rows = dt };
            return JsonDate(result);
        }

        /// <summary>
        /// 审核页面 
        /// </summary>
        /// <returns></returns>
        public ActionResult Review()
        {
            return View();
        }

        /// <summary>
        /// 审核转科申请
        /// </summary>
        /// <param name="id"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public ActionResult ReviewSave(int id, int status, string reviewReason)
        {
            OperateResult resultInfo = NurseTransferManager.Review(id, status, reviewReason);
            return JsonDate(resultInfo);
        }
    }
}